package com.surenpi.jenkins.client.computer;

import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.surenpi.jenkins.client.BaseModel;
import com.surenpi.jenkins.client.JenkinsClient;
import java.util.List;

public class ComputerSet extends BaseModel {
   private int busyExecutors;
   List<ComputerWithDetails> computer;
   private String displayName;
   private int totalExecutors;
   private JenkinsClient client;

   public int getBusyExecutors() {
      return this.busyExecutors;
   }

   public void setBusyExecutors(int busyExecutors) {
      this.busyExecutors = busyExecutors;
   }

   public String getDisplayName() {
      return this.displayName;
   }

   public void setDisplayName(String displayName) {
      this.displayName = displayName;
   }

   public int getTotalExecutors() {
      return this.totalExecutors;
   }

   public void setTotalExecutors(int totalExecutors) {
      this.totalExecutors = totalExecutors;
   }

   public List<ComputerWithDetails> getComputers() {
      return Lists.transform(this.computer, new Function<ComputerWithDetails, ComputerWithDetails>() {
         public ComputerWithDetails apply(ComputerWithDetails computerWithDetails) {
            computerWithDetails.setClient(ComputerSet.this.client);
            return computerWithDetails;
         }
      });
   }

   public void setClient(JenkinsClient client) {
      this.client = client;
   }

   public JenkinsClient getClient() {
      return this.client;
   }

   public void setComputer(List<ComputerWithDetails> computers) {
      this.computer = computers;
   }

   public int hashCode() {
      int prime = 31;
      int result = 1;
      result = 31 * result + this.busyExecutors;
      result = 31 * result + (this.computer == null ? 0 : this.computer.hashCode());
      result = 31 * result + (this.displayName == null ? 0 : this.displayName.hashCode());
      result = 31 * result + this.totalExecutors;
      return result;
   }

   public boolean equals(Object obj) {
      if (this == obj) {
         return true;
      } else if (obj == null) {
         return false;
      } else if (this.getClass() != obj.getClass()) {
         return false;
      } else {
         ComputerSet other = (ComputerSet)obj;
         if (this.busyExecutors != other.busyExecutors) {
            return false;
         } else {
            if (this.computer == null) {
               if (other.computer != null) {
                  return false;
               }
            } else if (!this.computer.equals(other.computer)) {
               return false;
            }

            if (this.displayName == null) {
               if (other.displayName != null) {
                  return false;
               }
            } else if (!this.displayName.equals(other.displayName)) {
               return false;
            }

            return this.totalExecutors == other.totalExecutors;
         }
      }
   }
}
